package com.link.play.fit.ai.ui.main.saveFood.details

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import com.link.play.fit.ai.base.BaseActivity
import com.link.play.fit.ai.databinding.ModifyFoodNameLayoutBinding

class ModifyFoodNameAc : BaseActivity<ModifyFoodNameLayoutBinding>(ModifyFoodNameLayoutBinding::inflate)   {
    private var mName = ""
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initListener()
        initData()
    }

    private fun initListener(){
        with(binding){
            backImage.setOnClickListener {
                finish()
            }
            updateText.setOnClickListener {
                val intent = Intent().apply {
                    putExtra("result_key", binding.edittextName.text.toString())
                }
                setResult(Activity.RESULT_OK, intent)
                finish()
            }
        }
    }

    private fun initData(){
        mName = intent.getStringExtra("name").toString()
        binding.edittextName.setText(mName)
    }

}